package com.smartwebx.ha.dal.usebean;

import java.text.ParseException;
import java.util.Date;
import java.util.List;

import org.apache.commons.lang3.time.DateUtils;

import com.google.common.collect.Lists;
import com.google.common.collect.Ordering;

/**
 * 
 * 最高最低平均
 * 
 * @author XX
 * 
 */
public class FeatureHighLow {
	// 最高
	private double maxz;
	// 最高时间
	private Date maxzTm;
	// 最低
	private double minz;
	// 最低时间
	private Date minzTm;
	// 平均
	private double avgz;
	// 平均时间
	private Date avgTm;

	public Date getAvgTm() {
		return avgTm;
	}

	public void setAvgTm(String yr) {
		try {
			this.avgTm = DateUtils.parseDate(yr, "yyyy");
		} catch (ParseException e) {
			e.printStackTrace();
		}
	}

	public double getMaxz() {
		return maxz;
	}

	public void setMaxz(double maxz) {
		this.maxz = maxz;
	}

	public Date getMaxzTm() {
		return maxzTm;
	}

	public void setMaxzTm(Date maxzTm) {
		this.maxzTm = maxzTm;
	}

	public double getMinz() {
		return minz;
	}

	public void setMinz(double minz) {
		this.minz = minz;
	}

	public Date getMinzTm() {
		return minzTm;
	}

	public void setMinzTm(Date minzTm) {
		this.minzTm = minzTm;
	}

	public double getAvgz() {
		return avgz;
	}

	public void setAvgz(double avgz) {
		this.avgz = avgz;
	}

	public static Ordering<FeatureHighLow> minByOrder = new Ordering<FeatureHighLow>() {
		@Override
		public int compare(FeatureHighLow left, FeatureHighLow right) {
			return Double.compare(left.getMinz(), right.getMinz());
		}
	};

	public static Ordering<FeatureHighLow> maxByOrder = new Ordering<FeatureHighLow>() {
		@Override
		public int compare(FeatureHighLow left, FeatureHighLow right) {
			return Double.compare(left.getMaxz(), right.getMaxz());
		}
	};
	
	
	public static void main(String args[]){
		List<FeatureHighLow> highLows = Lists.newArrayList();
		FeatureHighLow highLow = new FeatureHighLow();
		highLow.setMaxz(1);
		highLows.add(highLow);
		highLow = new FeatureHighLow();
		highLows.add(highLow);
		highLow = new FeatureHighLow();
		highLows.add(highLow);
		highLow = new FeatureHighLow();
		highLows.add(highLow);
		
		FeatureHighLow max = FeatureHighLow.maxByOrder.max(highLows);
		System.out.println(max);
	}

}
